from zope.component import getMultiAdapter
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from plone.app.layout.viewlets import common
from plone.app.portlets.portlets.login import Renderer

# Sample code for a basic viewlet (In order to use it, you'll have to):
# - Un-comment the following useable piece of code (viewlet python class).
# - Rename the vielwet template file ('browser/viewlet.pt') and edit the
#   following python code accordingly.
# - Edit the class and template to make them suit your needs.
# - Make sure your viewlet is correctly registered in 'browser/configure.zcml'.
# - If you need it to appear in a specific order inside its viewlet manager,
#   edit 'profiles/default/viewlets.xml' accordingly.
# - Restart Zope.
# - If you edited any file in 'profiles/default/', reinstall your package.
# - Once you're happy with your viewlet implementation, remove any related
#   (unwanted) inline documentation  ;-p

#class MyViewlet(common.ViewletBase):
#    render = ViewPageTemplateFile('viewlet.pt')
#    def update(self):
#        self.computed_value = 'any output'


class TchezopeSiteActionsViewlet(common.SiteActionsViewlet):
    """ SiteAction implementa o metodo render que sobrescreve a diretiva zcml
    """
    render = ViewPageTemplateFile('templates/site_actions.pt')


class TchezopePersonalBarViewlet(common.PersonalBarViewlet):
    """ PersonalBarViewlet implementa o metodo render que sobrescreve a diretiva zcml
    """

    _render = ViewPageTemplateFile('templates/personal_bar.pt')

    def render(self):
        if not self.anonymous:
            return self._render()
        else:
            return u''

